package graphicUserInterface.mainInterface.screenDrawing;

import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;

public class FirstScreenDrawer {
	/* *********************************************************
	 * Static Methods
	 * ********************************************************* */
	/**
	 * create a JPanel and draw the firstScreen in this Panel
	 * @param actionToPerform action performed by the first 
	 * screen's button
	 * @return a JPanel containing all the things needed by the 
	 * first screen
	 */
	public static JPanel build(ActionListener actionToPerform){
		System.out.println("GUI:FstScreenDrawer build");
		//fst create the center container :
		JPanel center = new JPanel();
		//ask for drawing the center
		draw(center, actionToPerform);
		//then it's over just return the screen
		return center;
	}
	/**
	 * put all the things needed by the first screen in the given
	 * panel 
	 * NOTE : you should call validate on this Panel if it's already
	 * displayed
	 * @param container the JPanel to transform in a firstScreen 
	 * (note: previous content will be remove...)
	 * @param actionToPerform action performed by the first 
	 * screen's button
	 */
	public static void draw(JPanel container,
			ActionListener actionToPerform){
		System.out.println("GUI:CalibrationScreenDrawer  draw");
		container.removeAll();
		container.setLayout(
				new BoxLayout(container, BoxLayout.Y_AXIS));
		//then add the title
		container.add(
				new JLabel("Hello people ! And welcome in HINB !", SwingConstants.CENTER));
		//create the container to be display right under the title
		JPanel subCenter = new JPanel();
		subCenter.setLayout(new GridLayout(2, 2));
		//then create the 4 parts of this container
		JTextPane fstText = new JTextPane();
		fstText.setText("HINB Is Not BlobbyVolley, it's way better!\n" +
				"\nHINB is a simple volleyball game where the players " +
				"are controlled by the movements of a player's hand in" +
				" front of his webcam.\n\nEach player is represented " +
				"by a snowman, a penguin being the ball. The net is a " +
				"pine tree\n\nMovements to the left or to the right " +
				"makes the snowmen move right or left. Rapid up " +
				"movements make them jump.");
		fstText.setEditable(false);
		subCenter.add(fstText);
		JLabel fstPict = new JLabel(
				new ImageIcon("assets/images/screenshot.jpg"));
		subCenter.add(fstPict);
		JLabel sndPict = new JLabel(
				new ImageIcon("assets/images/screenshot.jpg"));
		subCenter.add(sndPict);
		//the last part will containe a textbloc and a button to the
		// next screen
		JPanel lastSubCenterPart = new JPanel();
		lastSubCenterPart.setLayout(
				new BoxLayout(lastSubCenterPart, BoxLayout.Y_AXIS));
		//create the text for the last part
		JTextPane sndText = new JTextPane();
		sndText.setText("Are you ready to smash the penguin?");
		sndText.setEditable(false);
		lastSubCenterPart.add(sndText);
		//create the button
		JButton nextScreenButton = new JButton("Let's go !");
		nextScreenButton.addActionListener(actionToPerform);
		lastSubCenterPart.add(nextScreenButton);
		//finally add the last part to the subscreen :-p
		subCenter.add(lastSubCenterPart);
		//and add the subCenter to the center : 
		container.add(subCenter);
		System.out.println("GUI:CalibrationScreenDrawer  Drawing over");
	}
}
